/**
 * Created by lihao on 2017/3/7.
 */
//接口服务
"use strict";

module.exports = function () {
        return {
            formatSendVal:function (form) {
                //序列化表单内元素
                return _.transform(_.chain($(form).find('input[name]')).map(function (n) {
                    if($(n).data('isSend') != undefined){
                        if(!_.isEmpty(n.name) && $(n).data('isSend')){
                            return {name:$(n).attr('name'),val:$(n).val()};
                        }else{
                            return ''
                        }
                    }else{
                        return {name:$(n).attr('name'),val:$(n).val()};
                    }
                }).thru(function (arr) {
                    return _.compact(arr);
                }).value(),function (result,n) {
                    result[n.name] = n.val;
                },{});
            },
        }
}();